package torque.generated;


import java.math.BigDecimal;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang.ObjectUtils;
import org.apache.torque.TorqueException;
import org.apache.torque.map.TableMap;
import org.apache.torque.om.BaseObject;
import org.apache.torque.om.ComboKey;
import org.apache.torque.om.DateKey;
import org.apache.torque.om.NumberKey;
import org.apache.torque.om.ObjectKey;
import org.apache.torque.om.SimpleKey;
import org.apache.torque.om.StringKey;
import org.apache.torque.om.Persistent;
import org.apache.torque.util.Criteria;
import org.apache.torque.util.Transaction;





/**
 * inventaire Table
 *
 * This class was autogenerated by Torque on:
 *
 * [Wed Mar 21 10:21:18 CET 2012]
 *
 * You should not use this class directly.  It should not even be
 * extended all references should be to Inventaire
 */
public abstract class BaseInventaire extends BaseObject
{
    /** Serial version */
    private static final long serialVersionUID = 1332321678105L;

    /** The Peer class */
    private static final InventairePeer peer =
        new InventairePeer();

    /** The value for the idinventaire field */
    private int idinventaire;

    /** The value for the nomvaisseau field */
    private String nomvaisseau;

    /** The value for the nbslot field */
    private int nbslot;

    /** The value for the nompartie field */
    private String nompartie;

    /** The value for the datepartie field */
    private Date datepartie;


    /**
     * Get the Idinventaire
     *
     * @return int
     */
    public int getIdinventaire()
    {
        return idinventaire;
    }


    /**
     * Set the value of Idinventaire
     *
     * @param v new value
     */
    public void setIdinventaire(int v) throws TorqueException
    {

        if (this.idinventaire != v)
        {
            this.idinventaire = v;
            setModified(true);
        }



        // update associated Objetinventaire
        if (collObjetinventaires != null)
        {
            for (int i = 0; i < collObjetinventaires.size(); i++)
            {
                ((Objetinventaire) collObjetinventaires.get(i))
                        .setIdinv(v);
            }
        }
    }

    /**
     * Get the Nomvaisseau
     *
     * @return String
     */
    public String getNomvaisseau()
    {
        return nomvaisseau;
    }


    /**
     * Set the value of Nomvaisseau
     *
     * @param v new value
     */
    public void setNomvaisseau(String v) 
    {

        if (!ObjectUtils.equals(this.nomvaisseau, v))
        {
            this.nomvaisseau = v;
            setModified(true);
        }


    }

    /**
     * Get the Nbslot
     *
     * @return int
     */
    public int getNbslot()
    {
        return nbslot;
    }


    /**
     * Set the value of Nbslot
     *
     * @param v new value
     */
    public void setNbslot(int v) 
    {

        if (this.nbslot != v)
        {
            this.nbslot = v;
            setModified(true);
        }


    }

    /**
     * Get the Nompartie
     *
     * @return String
     */
    public String getNompartie()
    {
        return nompartie;
    }


    /**
     * Set the value of Nompartie
     *
     * @param v new value
     */
    public void setNompartie(String v) throws TorqueException
    {

        if (!ObjectUtils.equals(this.nompartie, v))
        {
            this.nompartie = v;
            setModified(true);
        }


        if (aPartie != null && !ObjectUtils.equals(aPartie.getNomp(), v))
        {
            aPartie = null;
        }

    }

    /**
     * Get the Datepartie
     *
     * @return Date
     */
    public Date getDatepartie()
    {
        return datepartie;
    }


    /**
     * Set the value of Datepartie
     *
     * @param v new value
     */
    public void setDatepartie(Date v) 
    {

        if (!ObjectUtils.equals(this.datepartie, v))
        {
            this.datepartie = v;
            setModified(true);
        }


    }

    



    private Partie aPartie;

    /**
     * Declares an association between this object and a Partie object
     *
     * @param v Partie
     * @throws TorqueException
     */
    public void setPartie(Partie v) throws TorqueException
    {
        if (v == null)
        {
            setNompartie((String) null);
        }
        else
        {
            setNompartie(v.getNomp());
        }
        aPartie = v;
    }


    /**
     * Returns the associated Partie object.
     * If it was not retrieved before, the object is retrieved from
     * the database
     *
     * @return the associated Partie object
     * @throws TorqueException
     */
    public Partie getPartie()
        throws TorqueException
    {
        if (aPartie == null && (!ObjectUtils.equals(this.nompartie, null)))
        {
            aPartie = PartiePeer.retrieveByPK(SimpleKey.keyFor(this.nompartie));
        }
        return aPartie;
    }

    /**
     * Return the associated Partie object
     * If it was not retrieved before, the object is retrieved from
     * the database using the passed connection
     *
     * @param connection the connection used to retrieve the associated object
     *        from the database, if it was not retrieved before
     * @return the associated Partie object
     * @throws TorqueException
     */
    public Partie getPartie(Connection connection)
        throws TorqueException
    {
        if (aPartie == null && (!ObjectUtils.equals(this.nompartie, null)))
        {
            aPartie = PartiePeer.retrieveByPK(SimpleKey.keyFor(this.nompartie), connection);
        }
        return aPartie;
    }

    /**
     * Provides convenient way to set a relationship based on a
     * ObjectKey, for example
     * <code>bar.setFooKey(foo.getPrimaryKey())</code>
     *
     */
    public void setPartieKey(ObjectKey key) throws TorqueException
    {

        setNompartie(key.toString());
    }
   


    /**
     * Collection to store aggregation of collObjetinventaires
     */
    protected List collObjetinventaires;

    /**
     * Temporary storage of collObjetinventaires to save a possible db hit in
     * the event objects are add to the collection, but the
     * complete collection is never requested.
     */
    protected void initObjetinventaires()
    {
        if (collObjetinventaires == null)
        {
            collObjetinventaires = new ArrayList();
        }
    }


    /**
     * Method called to associate a Objetinventaire object to this object
     * through the Objetinventaire foreign key attribute
     *
     * @param l Objetinventaire
     * @throws TorqueException
     */
    public void addObjetinventaire(Objetinventaire l) throws TorqueException
    {
        getObjetinventaires().add(l);
        l.setInventaire((Inventaire) this);
    }

    /**
     * Method called to associate a Objetinventaire object to this object
     * through the Objetinventaire foreign key attribute using connection.
     *
     * @param l Objetinventaire
     * @throws TorqueException
     */
    public void addObjetinventaire(Objetinventaire l, Connection con) throws TorqueException
    {
        getObjetinventaires(con).add(l);
        l.setInventaire((Inventaire) this);
    }

    /**
     * The criteria used to select the current contents of collObjetinventaires
     */
    private Criteria lastObjetinventairesCriteria = null;

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getObjetinventaires(new Criteria())
     *
     * @return the collection of associated objects
     * @throws TorqueException
     */
    public List getObjetinventaires()
        throws TorqueException
    {
        if (collObjetinventaires == null)
        {
            collObjetinventaires = getObjetinventaires(new Criteria(10));
        }
        return collObjetinventaires;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Inventaire has previously
     * been saved, it will retrieve related Objetinventaires from storage.
     * If this Inventaire is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     *
     * @throws TorqueException
     */
    public List getObjetinventaires(Criteria criteria) throws TorqueException
    {
        if (collObjetinventaires == null)
        {
            if (isNew())
            {
               collObjetinventaires = new ArrayList();
            }
            else
            {
                criteria.add(ObjetinventairePeer.IDINV, getIdinventaire() );
                collObjetinventaires = ObjetinventairePeer.doSelect(criteria);
            }
        }
        else
        {
            // criteria has no effect for a new object
            if (!isNew())
            {
                // the following code is to determine if a new query is
                // called for.  If the criteria is the same as the last
                // one, just return the collection.
                criteria.add(ObjetinventairePeer.IDINV, getIdinventaire());
                if (!lastObjetinventairesCriteria.equals(criteria))
                {
                    collObjetinventaires = ObjetinventairePeer.doSelect(criteria);
                }
            }
        }
        lastObjetinventairesCriteria = criteria;

        return collObjetinventaires;
    }

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getObjetinventaires(new Criteria(),Connection)
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getObjetinventaires(Connection con) throws TorqueException
    {
        if (collObjetinventaires == null)
        {
            collObjetinventaires = getObjetinventaires(new Criteria(10), con);
        }
        return collObjetinventaires;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Inventaire has previously
     * been saved, it will retrieve related Objetinventaires from storage.
     * If this Inventaire is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getObjetinventaires(Criteria criteria, Connection con)
            throws TorqueException
    {
        if (collObjetinventaires == null)
        {
            if (isNew())
            {
               collObjetinventaires = new ArrayList();
            }
            else
            {
                 criteria.add(ObjetinventairePeer.IDINV, getIdinventaire());
                 collObjetinventaires = ObjetinventairePeer.doSelect(criteria, con);
             }
         }
         else
         {
             // criteria has no effect for a new object
             if (!isNew())
             {
                 // the following code is to determine if a new query is
                 // called for.  If the criteria is the same as the last
                 // one, just return the collection.
                 criteria.add(ObjetinventairePeer.IDINV, getIdinventaire());
                 if (!lastObjetinventairesCriteria.equals(criteria))
                 {
                     collObjetinventaires = ObjetinventairePeer.doSelect(criteria, con);
                 }
             }
         }
         lastObjetinventairesCriteria = criteria;

         return collObjetinventaires;
     }











    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Inventaire is new, it will return
     * an empty collection; or if this Inventaire has previously
     * been saved, it will retrieve related Objetinventaires from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Inventaire.
     */
    protected List getObjetinventairesJoinObjet(Criteria criteria)
        throws TorqueException
    {
        if (collObjetinventaires == null)
        {
            if (isNew())
            {
               collObjetinventaires = new ArrayList();
            }
            else
            {
                criteria.add(ObjetinventairePeer.IDINV, getIdinventaire());
                collObjetinventaires = ObjetinventairePeer.doSelectJoinObjet(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            criteria.add(ObjetinventairePeer.IDINV, getIdinventaire());
            if (!lastObjetinventairesCriteria.equals(criteria))
            {
                collObjetinventaires = ObjetinventairePeer.doSelectJoinObjet(criteria);
            }
        }
        lastObjetinventairesCriteria = criteria;

        return collObjetinventaires;
    }









    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Inventaire is new, it will return
     * an empty collection; or if this Inventaire has previously
     * been saved, it will retrieve related Objetinventaires from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Inventaire.
     */
    protected List getObjetinventairesJoinInventaire(Criteria criteria)
        throws TorqueException
    {
        if (collObjetinventaires == null)
        {
            if (isNew())
            {
               collObjetinventaires = new ArrayList();
            }
            else
            {
                criteria.add(ObjetinventairePeer.IDINV, getIdinventaire());
                collObjetinventaires = ObjetinventairePeer.doSelectJoinInventaire(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            criteria.add(ObjetinventairePeer.IDINV, getIdinventaire());
            if (!lastObjetinventairesCriteria.equals(criteria))
            {
                collObjetinventaires = ObjetinventairePeer.doSelectJoinInventaire(criteria);
            }
        }
        lastObjetinventairesCriteria = criteria;

        return collObjetinventaires;
    }



        
    private static List fieldNames = null;

    /**
     * Generate a list of field names.
     *
     * @return a list of field names
     */
    public static synchronized List getFieldNames()
    {
        if (fieldNames == null)
        {
            fieldNames = new ArrayList();
            fieldNames.add("Idinventaire");
            fieldNames.add("Nomvaisseau");
            fieldNames.add("Nbslot");
            fieldNames.add("Nompartie");
            fieldNames.add("Datepartie");
            fieldNames = Collections.unmodifiableList(fieldNames);
        }
        return fieldNames;
    }

    /**
     * Retrieves a field from the object by field (Java) name passed in as a String.
     *
     * @param name field name
     * @return value
     */
    public Object getByName(String name)
    {
        if (name.equals("Idinventaire"))
        {
            return new Integer(getIdinventaire());
        }
        if (name.equals("Nomvaisseau"))
        {
            return getNomvaisseau();
        }
        if (name.equals("Nbslot"))
        {
            return new Integer(getNbslot());
        }
        if (name.equals("Nompartie"))
        {
            return getNompartie();
        }
        if (name.equals("Datepartie"))
        {
            return getDatepartie();
        }
        return null;
    }

    /**
     * Set a field in the object by field (Java) name.
     *
     * @param name field name
     * @param value field value
     * @return True if value was set, false if not (invalid name / protected field).
     * @throws IllegalArgumentException if object type of value does not match field object type.
     * @throws TorqueException If a problem occurs with the set[Field] method.
     */
    public boolean setByName(String name, Object value )
        throws TorqueException, IllegalArgumentException
    {
        if (name.equals("Idinventaire"))
        {
            if (value == null || ! (Integer.class.isInstance(value)))
            {
                throw new IllegalArgumentException("setByName: value parameter was null or not an Integer object.");
            }
            setIdinventaire(((Integer) value).intValue());
            return true;
        }
        if (name.equals("Nomvaisseau"))
        {
            // Object fields can be null
            if (value != null && ! String.class.isInstance(value))
            {
                throw new IllegalArgumentException("Invalid type of object specified for value in setByName");
            }
            setNomvaisseau((String) value);
            return true;
        }
        if (name.equals("Nbslot"))
        {
            if (value == null || ! (Integer.class.isInstance(value)))
            {
                throw new IllegalArgumentException("setByName: value parameter was null or not an Integer object.");
            }
            setNbslot(((Integer) value).intValue());
            return true;
        }
        if (name.equals("Nompartie"))
        {
            // Object fields can be null
            if (value != null && ! String.class.isInstance(value))
            {
                throw new IllegalArgumentException("Invalid type of object specified for value in setByName");
            }
            setNompartie((String) value);
            return true;
        }
        if (name.equals("Datepartie"))
        {
            // Object fields can be null
            if (value != null && ! Date.class.isInstance(value))
            {
                throw new IllegalArgumentException("Invalid type of object specified for value in setByName");
            }
            setDatepartie((Date) value);
            return true;
        }
        return false;
    }

    /**
     * Retrieves a field from the object by name passed in
     * as a String.  The String must be one of the static
     * Strings defined in this Class' Peer.
     *
     * @param name peer name
     * @return value
     */
    public Object getByPeerName(String name)
    {
        if (name.equals(InventairePeer.IDINVENTAIRE))
        {
            return new Integer(getIdinventaire());
        }
        if (name.equals(InventairePeer.NOMVAISSEAU))
        {
            return getNomvaisseau();
        }
        if (name.equals(InventairePeer.NBSLOT))
        {
            return new Integer(getNbslot());
        }
        if (name.equals(InventairePeer.NOMPARTIE))
        {
            return getNompartie();
        }
        if (name.equals(InventairePeer.DATEPARTIE))
        {
            return getDatepartie();
        }
        return null;
    }

    /**
     * Set field values by Peer Field Name
     *
     * @param name field name
     * @param value field value
     * @return True if value was set, false if not (invalid name / protected field).
     * @throws IllegalArgumentException if object type of value does not match field object type.
     * @throws TorqueException If a problem occurs with the set[Field] method.
     */
    public boolean setByPeerName(String name, Object value)
        throws TorqueException, IllegalArgumentException
    {
      if (InventairePeer.IDINVENTAIRE.equals(name))
        {
            return setByName("Idinventaire", value);
        }
      if (InventairePeer.NOMVAISSEAU.equals(name))
        {
            return setByName("Nomvaisseau", value);
        }
      if (InventairePeer.NBSLOT.equals(name))
        {
            return setByName("Nbslot", value);
        }
      if (InventairePeer.NOMPARTIE.equals(name))
        {
            return setByName("Nompartie", value);
        }
      if (InventairePeer.DATEPARTIE.equals(name))
        {
            return setByName("Datepartie", value);
        }
        return false;
    }

    /**
     * Retrieves a field from the object by Position as specified
     * in the xml schema.  Zero-based.
     *
     * @param pos position in xml schema
     * @return value
     */
    public Object getByPosition(int pos)
    {
        if (pos == 0)
        {
            return new Integer(getIdinventaire());
        }
        if (pos == 1)
        {
            return getNomvaisseau();
        }
        if (pos == 2)
        {
            return new Integer(getNbslot());
        }
        if (pos == 3)
        {
            return getNompartie();
        }
        if (pos == 4)
        {
            return getDatepartie();
        }
        return null;
    }

    /**
     * Set field values by its position (zero based) in the XML schema.
     *
     * @param position The field position
     * @param value field value
     * @return True if value was set, false if not (invalid position / protected field).
     * @throws IllegalArgumentException if object type of value does not match field object type.
     * @throws TorqueException If a problem occurs with the set[Field] method.
     */
    public boolean setByPosition(int position, Object value)
        throws TorqueException, IllegalArgumentException
    {
    if (position == 0)
        {
            return setByName("Idinventaire", value);
        }
    if (position == 1)
        {
            return setByName("Nomvaisseau", value);
        }
    if (position == 2)
        {
            return setByName("Nbslot", value);
        }
    if (position == 3)
        {
            return setByName("Nompartie", value);
        }
    if (position == 4)
        {
            return setByName("Datepartie", value);
        }
        return false;
    }
     
    /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.
     *
     * @throws Exception
     */
    public void save() throws Exception
    {
        save(InventairePeer.DATABASE_NAME);
    }

    /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.
     * Note: this code is here because the method body is
     * auto-generated conditionally and therefore needs to be
     * in this file instead of in the super class, BaseObject.
     *
     * @param dbName
     * @throws TorqueException
     */
    public void save(String dbName) throws TorqueException
    {
        Connection con = null;
        try
        {
            con = Transaction.begin(dbName);
            save(con);
            Transaction.commit(con);
        }
        catch(TorqueException e)
        {
            Transaction.safeRollback(con);
            throw e;
        }
    }

    /** flag to prevent endless save loop, if this object is referenced
        by another object which falls in this transaction. */
    private boolean alreadyInSave = false;
    /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.  This method
     * is meant to be used as part of a transaction, otherwise use
     * the save() method and the connection details will be handled
     * internally
     *
     * @param con
     * @throws TorqueException
     */
    public void save(Connection con) throws TorqueException
    {
        if (!alreadyInSave)
        {
            alreadyInSave = true;



            // If this object has been modified, then save it to the database.
            if (isModified())
            {
                if (isNew())
                {
                    InventairePeer.doInsert((Inventaire) this, con);
                    setNew(false);
                }
                else
                {
                    InventairePeer.doUpdate((Inventaire) this, con);
                }
            }


            if (collObjetinventaires != null)
            {
                for (int i = 0; i < collObjetinventaires.size(); i++)
                {
                    ((Objetinventaire) collObjetinventaires.get(i)).save(con);
                }
            }
            alreadyInSave = false;
        }
    }


    /**
     * Set the PrimaryKey using ObjectKey.
     *
     * @param key idinventaire ObjectKey
     */
    public void setPrimaryKey(ObjectKey key)
        throws TorqueException
    {
        setIdinventaire(((NumberKey) key).intValue());
    }

    /**
     * Set the PrimaryKey using a String.
     *
     * @param key
     */
    public void setPrimaryKey(String key) throws TorqueException
    {
        setIdinventaire(Integer.parseInt(key));
    }


    /**
     * returns an id that differentiates this object from others
     * of its class.
     */
    public ObjectKey getPrimaryKey()
    {
        return SimpleKey.keyFor(getIdinventaire());
    }
 

    /**
     * Makes a copy of this object.
     * It creates a new object filling in the simple attributes.
     * It then fills all the association collections and sets the
     * related objects to isNew=true.
     */
    public Inventaire copy() throws TorqueException
    {
        return copy(true);
    }

    /**
     * Makes a copy of this object using connection.
     * It creates a new object filling in the simple attributes.
     * It then fills all the association collections and sets the
     * related objects to isNew=true.
     *
     * @param con the database connection to read associated objects.
     */
    public Inventaire copy(Connection con) throws TorqueException
    {
        return copy(true, con);
    }

    /**
     * Makes a copy of this object.
     * It creates a new object filling in the simple attributes.
     * If the parameter deepcopy is true, it then fills all the
     * association collections and sets the related objects to
     * isNew=true.
     *
     * @param deepcopy whether to copy the associated objects.
     */
    public Inventaire copy(boolean deepcopy) throws TorqueException
    {
        return copyInto(new Inventaire(), deepcopy);
    }

    /**
     * Makes a copy of this object using connection.
     * It creates a new object filling in the simple attributes.
     * If the parameter deepcopy is true, it then fills all the
     * association collections and sets the related objects to
     * isNew=true.
     *
     * @param deepcopy whether to copy the associated objects.
     * @param con the database connection to read associated objects.
     */
    public Inventaire copy(boolean deepcopy, Connection con) throws TorqueException
    {
        return copyInto(new Inventaire(), deepcopy, con);
    }
  
    /**
     * Fills the copyObj with the contents of this object.
     * The associated objects are also copied and treated as new objects.
     *
     * @param copyObj the object to fill.
     */
    protected Inventaire copyInto(Inventaire copyObj) throws TorqueException
    {
        return copyInto(copyObj, true);
    }

  
    /**
     * Fills the copyObj with the contents of this object using connection.
     * The associated objects are also copied and treated as new objects.
     *
     * @param copyObj the object to fill.
     * @param con the database connection to read associated objects.
     */
    protected Inventaire copyInto(Inventaire copyObj, Connection con) throws TorqueException
    {
        return copyInto(copyObj, true, con);
    }
  
    /**
     * Fills the copyObj with the contents of this object.
     * If deepcopy is true, The associated objects are also copied
     * and treated as new objects.
     *
     * @param copyObj the object to fill.
     * @param deepcopy whether the associated objects should be copied.
     */
    protected Inventaire copyInto(Inventaire copyObj, boolean deepcopy) throws TorqueException
    {
        copyObj.setIdinventaire(idinventaire);
        copyObj.setNomvaisseau(nomvaisseau);
        copyObj.setNbslot(nbslot);
        copyObj.setNompartie(nompartie);
        copyObj.setDatepartie(datepartie);

        copyObj.setIdinventaire( 0);

        if (deepcopy)
        {


        List vObjetinventaires = getObjetinventaires();
        if (vObjetinventaires != null)
        {
            for (int i = 0; i < vObjetinventaires.size(); i++)
            {
                Objetinventaire obj = (Objetinventaire) vObjetinventaires.get(i);
                copyObj.addObjetinventaire(obj.copy());
            }
        }
        else
        {
            copyObj.collObjetinventaires = null;
        }
        }
        return copyObj;
    }
        
    
    /**
     * Fills the copyObj with the contents of this object using connection.
     * If deepcopy is true, The associated objects are also copied
     * and treated as new objects.
     *
     * @param copyObj the object to fill.
     * @param deepcopy whether the associated objects should be copied.
     * @param con the database connection to read associated objects.
     */
    protected Inventaire copyInto(Inventaire copyObj, boolean deepcopy, Connection con) throws TorqueException
    {
        copyObj.setIdinventaire(idinventaire);
        copyObj.setNomvaisseau(nomvaisseau);
        copyObj.setNbslot(nbslot);
        copyObj.setNompartie(nompartie);
        copyObj.setDatepartie(datepartie);

        copyObj.setIdinventaire( 0);

        if (deepcopy)
        {


        List vObjetinventaires = getObjetinventaires(con);
        if (vObjetinventaires != null)
        {
            for (int i = 0; i < vObjetinventaires.size(); i++)
            {
                Objetinventaire obj = (Objetinventaire) vObjetinventaires.get(i);
                copyObj.addObjetinventaire(obj.copy(con), con);
            }
        }
        else
        {
            copyObj.collObjetinventaires = null;
        }
        }
        return copyObj;
    }
    
    

    /**
     * returns a peer instance associated with this om.  Since Peer classes
     * are not to have any instance attributes, this method returns the
     * same instance for all member of this class. The method could therefore
     * be static, but this would prevent one from overriding the behavior.
     */
    public InventairePeer getPeer()
    {
        return peer;
    }

    /**
     * Retrieves the TableMap object related to this Table data without
     * compiler warnings of using getPeer().getTableMap().
     *
     * @return The associated TableMap object.
     */
    public TableMap getTableMap() throws TorqueException
    {
        return InventairePeer.getTableMap();
    }


    public String toString()
    {
        StringBuffer str = new StringBuffer();
        str.append("Inventaire:\n");
        str.append("Idinventaire = ")
           .append(getIdinventaire())
           .append("\n");
        str.append("Nomvaisseau = ")
           .append(getNomvaisseau())
           .append("\n");
        str.append("Nbslot = ")
           .append(getNbslot())
           .append("\n");
        str.append("Nompartie = ")
           .append(getNompartie())
           .append("\n");
        str.append("Datepartie = ")
           .append(getDatepartie())
           .append("\n");
        return(str.toString());
    }
}
